function resid = solve_nwfun(G,  c,rho0,omega0,gamma1,gamma2)

thetaG    = (G.^gamma2  - G)    ./ (G.^gamma2  - G.^gamma1 );
thetainvG = (G.^-gamma2 - G.^-1)./ (G.^-gamma2 - G.^-gamma1);
phiG    = 1 - (thetaG   /gamma1) - ((1-thetaG)   /gamma2);
phiinvG = 1 - (thetainvG/gamma1) - ((1-thetainvG)/gamma2);
lhs = (phiinvG./phiG).*G;
rhs = (rho0*c/omega0) +1;
resid= lhs - rhs;